/**
 * @Author: Renyc
 * @Date: 2022-11-30 16:51:28
 */
import * as Cesium from 'cesium/Cesium';   
import TerrainType from './TerrainType';
import GPlatesTerrainProvider from './GPlatesTerrainProvider';

class TerrainFactory{

    /**
     * 创建Cesium的WorldTerrainProvider对象
     * @param  options 
     * @returns {cesium.CesiumTerrainProvider}
     */
    static createWorldTerrain(options) {
        return new Cesium.createWorldTerrain(options);
    }

    /**
     * 自定义地形数据，URL规范为TMS的{z}/{x}/{y}.terrain
     * options的格式为
     * {
     *      url : 'http://<host>/service
     * }
     * @param  options 
     * @returns {Cesium.CesiumTerrainProvider}
     */
    static createCustomXYZTerrain(options){
        return new Cesium.CesiumTerrainProvider(options);
    }

    static createGPlatesTerrain(){
        // let options = {
        //     url : '/get_terrain/?x={x}&y={y}&z={z}&name=topo15'
        // }
        // return new Cesium.CesiumTerrainProvider(options);
        let options = {

        };
        let provider = new GPlatesTerrainProvider(options);
        return provider;
    }

    static createTerrain(type, options){
        let terrain = undefined;
        switch(type){
            case TerrainType.XYZ:{
                terrain = this.createCustomXYZTerrain(options);
                break;
            }
            case TerrainType.CESIUM:{
                terrain = this.createWorldTerrain(options);
                break;
            }
            case TerrainType.GPLATES:{
                terrain = this.createGPlatesTerrain();
                break;
            }
        }

        return terrain;
    }
}

export default TerrainFactory